import service from '@/utils/request'

export const useGen_template_treeApi = (id: number) => {
	return service.get('/gen/gen_template_tree/' + id)
}

export const useGen_template_treeSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.put('/gen/gen_template_tree', dataForm)
	} else {
		return service.post('/gen/gen_template_tree', dataForm)
	}
}

export const useGen_template_treeListApi = () => {
	return service.get('/gen/gen_template_tree/list')
}

export const useGen_template_treeNameListApi = (idList: number[]) => {
	return service.post('/gen/gen_template_tree/nameList', idList)
}

// 生成代码（zip压缩包）
export const useDownloadPkgApi = (templateId: number) => {
	location.href = import.meta.env.VITE_API_URL + '/gen/gen_template_tree/download?templateId=' + templateId
}